﻿using Autofac;
using Autofac.Integration.Mvc;
using Century.Business.CMS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebUI.App_Start
{
    public class IocConfig
    {
        public static void RegisterDependencies()
        {
            var builder = new ContainerBuilder();
            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterControllers(typeof(Century.Member.Controllers.DashboardController).Assembly);
            builder.RegisterControllers(typeof(Century.Admin.Controllers.DashboardController).Assembly);
            builder.RegisterControllers(typeof(Century.CommonModule.Controllers.DashboardController).Assembly);

            builder.RegisterType<SecurityService>()
                .As<ISecurityService>()
                .InstancePerHttpRequest();

            builder.RegisterType<SiteService>()
                .As<ISiteService>()
                .InstancePerHttpRequest();

            IContainer container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
    }
}